<?PHP
// vim: set expandtab tabstop=4 shiftwidth=4:
// +----------------------------------------------------------------------+
// | SAPID: XML Sapiens Engine Demonstrator                               |
// +----------------------------------------------------------------------+
// | Author:  Max Baryshnikov aka Mephius <mb@redgraphic.com>             |
// |  		  Dmitry Sheiko <sheiko@cmsdevelopment.com>	                  |
// | Copyright (c) 2004 Max Baryshnikov                                   |
// | http://sapid.sourceforge.net	                                      |
// +----------------------------------------------------------------------+
// | This source file is free software; you can redistribute it and/or    |
// | modify it under the terms of the GNU Lesser General Public           |
// | License as published by the Free Software Foundation; either         |
// | version 2.1 of the License, or (at your option) any later version.   |
// |                                                                      |
// | This source file is distributed in the hope that it will be useful,  |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of       |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU    |
// | Lesser General Public License for more details.                      |
// +----------------------------------------------------------------------+
// Release: 12.03.05 (dd/mm/yy)
// $Id: admin_panel.inc.php,v 1.6 2006/02/20 08:42:11 sheiko Exp $

	if($_POST["mode"]=="expert") $env["user"]["mode"]="expert";

	$mode = $_GET["mode"];
	if($mode=="edit")
	$seo = '<td class="cell">&nbsp;<b><a style="color: #003263; font-size: 11px; CURSOR: pointer" onclick="if( meta.style.display==\'none\')  meta.style.display=\'block\'; else meta.style.display=\'none\';"><img src="'.$env["http_path"].'usr/system/images/meta.gif" height="14" width="12" alt="'.$lang["DocMetaData"].'" />&nbsp;'.$lang["DocMetaData"].'</a></b></td>';
	else $seo = '';
	
	$local_perm = 
	($env["page"]["pRead"]?"r":"-").
	($env["page"]["pWrite"]?"w":"-").
	($env["page"]["pCreate"]?"c":"-");

	
	$title_info_gray = ($env["document.title"]? '<td class="cell" style="color: #2D6FAF">&nbsp;<img src="'.$env["http_path"].'usr/system/images/title.gif" height="14" width="12" alt="TITLE" />&nbsp;<b>TITLE:</b>&nbsp;'.$env["document.title"].'</td>':'');
	$data_info = (($env["page"]["filemtime"] AND $env["page"]["ID"])? '<td class="cell">&nbsp;&nbsp;<img src="'.$env["http_path"].'usr/system/images/doc.gif" height="14" width="12" alt="'.$lang["Data"].'" />&nbsp;<b>'.$lang["Data"].':</b> '.$env["page"]["ID"].".xml".' '.date(PHP_DATEFORMAT, $env["page"]["filemtime"]).' '.$local_perm.'</td>' : '');
	$data_info_gray  = (($env["page"]["filemtime"] AND $env["page"]["ID"])? '<td class="cell" style="color: #2D6FAF">&nbsp;&nbsp;<img src="'.$env["http_path"].'usr/system/images/doc.gif" height="14" width="12" alt="'.$lang["Data"].'" />&nbsp;<b>'.$lang["Data"].':</b> '.$env["page"]["ID"].".xml".' '.date(PHP_DATEFORMAT, $env["page"]["filemtime"]).' '.$local_perm.'</td>' : '');
			

	$tools=($panel==""?'
<script>

	function move_panel(){
		document.getElementById(\'panel\').style.top=document.body.scrollTop-(pos=="shown"?0:64);
	}
	
	function slidebar(){
		if(pos==\'shown\'){
			if(document.getElementById(\'panel\').style.top.replace("px", "")>document.body.scrollTop-64) {
				document.getElementById(\'panel\').style.top=(document.getElementById(\'panel\').style.top.replace("px", "")*1)-1+\'px\';
				setTimeout("slidebar();", 10);
			}else{
				pos=\'hidden\';
				SetCookie(\'bar\', \'hidden\');
			}
		}else if(pos==\'hidden\'){
			if(document.getElementById(\'panel\').style.top.replace("px", "")<document.body.scrollTop) {
				document.getElementById(\'panel\').style.top=(document.getElementById(\'panel\').style.top.replace("px", "")*1)+1+\'px\';		
				setTimeout("slidebar();", 10);
			}else{
				pos=\'shown\';
				SetCookie(\'bar\', \'shown\');
			}
		}
	}
		
	function SetCookie (name, value) {
		var largeExpDate = new Date ();
		var argv = SetCookie.arguments;
		var argc = SetCookie.arguments.length;
		largeExpDate.setTime(largeExpDate.getTime() + (365 * 24 * 3600 * 1000));
		var expires = largeExpDate;
		document.cookie = name + "=" + escape (value) +"; expires=" + expires.toGMTString() +  "; path=/";
	}
	
	function getCookie(name) {
		if(document.cookie == "") return false; 
		else {
			var cookieStart, cookieEnd;
			var cookieString = document.cookie;
			cookieStart = cookieString.indexOf(name+"=");
			if(cookieStart != -1) {
			cookieStart += name.length+1;
			cookieEnd = cookieString.indexOf(";", cookieStart);
			if(cookieEnd == -1) cookieEnd = cookieString.length;
				return cookieString.substring(cookieStart, cookieEnd);
			} else {
				return false;
			}
		}
	}
	
	if(getCookie(\'bar\')) pos = getCookie(\'bar\'); else pos=\'shown\';
	
</script>	
	
	
	
<div id="panel" style="position: absolute; top: '.($_COOKIE["bar"]=="hidden"?"-64":"0").'px; left: 0px; z-index: 2;">':'').'
<table width="100%" cellpadding="0" cellspacing="0" border="0" class="sapidcms_sysblock_top" style="background-color: white;"> 
<tr>
	<td width="107" rowspan="2" ><a href="http://sapid.sf.net" title="Free ware CMS SAPID" target="_blank"><img src="'.$env["http_path"].'usr/system/images/logo.gif" width="107" height="55" border="0" alt="Free ware CMS SAPID" /></a></td>
	
	<td nowrap="nowrap" class="menu" title="'.$lang["StructureDescription"].'" onClick="location=\''.$env["http_path"].'?option=structure\'" >'.(in_array($_GET["option"], array("structure", "addpage"))?"<span style=\"color: #62BCFF\">".$lang["Structure"]."</span>":$lang["Structure"]).'</td>
	<td><img src="'.$env["http_path"].'usr/system/images/menu_vl.gif" width="2" height="30" alt="" /></td>
	'; if($env["user"]["GROUP"]=="wheel") $tools.='
	<td nowrap="nowrap" class="menu" title="'.$lang["TemplatesDescription"].'" onClick="location=\''.$env["http_path"].'?option=templates\'" >'.(in_array($_GET["option"], array("templates", "create_template"))?"<span  style=\"color: #62BCFF\">" . $lang["Templates"] . "</span>":$lang["Templates"]).'</td>
	<td><img src="'.$env["http_path"].'usr/system/images/menu_vl.gif" width="2" height="30" alt="" /></td>
	'; if($env["user"]["GROUP"]=="wheel" and $env["user"]["mode"]=="expert") $tools.='
	<td nowrap="nowrap" class="menu" title="'.$lang["DDCDescription"].'" title="" onClick="location=\''.$env["http_path"].'?option=ddc\'" >'.(in_array($_GET["option"], array("ddc", "create_ddc"))?"<span style=\"color: #62BCFF\">" . $lang["DDC"] . "</span>":$lang["DDC"]).'</td>
	<td><img src="'.$env["http_path"].'usr/system/images/menu_vl.gif" width="2" height="30" alt="" /></td>
	'; if($env["user"]["GROUP"]=="wheel" and $env["user"]["mode"]=="expert") $tools.='
	<td nowrap="nowrap" class="menu" title="'.$lang["FunctionsDescription"].'" onClick="location=\''.$env["http_path"].'?option=list_func\'" >'.(in_array($_GET["option"], array("list_func", "create_func"))?"<span style=\"color: #62BCFF\">" . $lang["User_Functions"] . "</span>":$lang["User_Functions"]).'</td>
	<td><img src="'.$env["http_path"].'usr/system/images/menu_vl.gif" width="2" height="30" alt="" /></td>
	'; if($env["user"]["GROUP"]=="wheel" and $env["user"]["mode"]=="expert") $tools.='
	<td nowrap="nowrap" class="menu" title="'.$lang["UsersDescription"].'" onClick="location=\''.$env["http_path"].'?option=users\'" >'.(in_array($_GET["option"], array("users", "edit_user", "delete_user", "create_user"))?"<span style=\"color: #62BCFF\">" . $lang["Users"] . "</span>":$lang["Users"]).'</td>
	<td><img src="'.$env["http_path"].'usr/system/images/menu_vl.gif" width="2" height="30" alt="" /></td>
	';
	$tools.='
	<td nowrap="nowrap" class="menu" title="'.$lang["StatisticDescription"].'" onClick="location=\''.$env["http_path"].'?option=stats\'" >'.(in_array($_GET["option"], array("stats"))?"<span style=\"color: #62BCFF\">" . $lang["Statistics"] . "</span>":$lang["Statistics"]).'</td>
	<td><img src="'.$env["http_path"].'usr/system/images/menu_vl.gif" width="2" height="30" alt="" /></td>
	
	<td nowrap="nowrap" width="100%" align="right" valign="top">
	
	<div style="margin: 0px 5px 0px 0px">
		<table cellpadding="0" cellspacing="0" border="0" style="padding: 5px 3px 0px 3px;">
			<tr>'.(($env["page"]["pWrite"] and $panel=="")?
	($_GET["mode"]=="edit"?'<td><a id="OK" style="cursor: pointer" onclick="'.substr(0, 5, time()).'_go();"><img src="'.$env["http_path"].'usr/system/images/'.$img_language.'/save.gif" alt="'.$lang["SaveBtn"].'"></a></td>
	 <td><a href="'.$action.($MODREWRITE=="disabled"?"&":"?").'mode=view"><img src="'.$env["http_path"].'usr/system/images/'.$img_language.'/cancel.gif" alt="'.$lang["CancelBtn"].'"></a></td>':
	'<td><a href="'.$action.($MODREWRITE=="disabled"?"&":"?").'mode=edit"><img src="'.$env["http_path"].'usr/system/images/'.$img_language.'/edit.gif" alt="'.$lang["EditBtn"].'"></a></td>
	 <td><a href="'.$action.($MODREWRITE=="disabled"?"&":"?").'mode=view"><img src="'.$env["http_path"].'usr/system/images/'.$img_language.'/view.gif" alt="'.$lang["ViewBtn"].'"></a></td>'):'<td><a href="'.$action.'?mode=view'.($MODREWRITE=="disabled"?"&vpath=".$_GET["vpath"]:"").'"><img src="'.$env["http_path"].'usr/system/images/'.$img_language.'/view.gif" alt="'.$lang["ViewBtn"].'"></a></td>').
	'<td><a href="'.$env["http_path"].'?logout=true"><img src="'.$env["http_path"].'usr/system/images/'.$img_language.'/logout.gif" alt="'.$lang["LogoutBtn"].'"></a></td>
			</tr>
		</table>
	</div>
	</td>
</tr>
<tr>
	<td colspan="13" nowrap="nowrap" width="100%" style="border-top: 1px solid white; height: 24px; background-color: #5DB1EF; vertical-align: middle;">
	<table style="padding-left: 5px" cellpadding="0" cellspacing="0" border="0" class="sapidcms_block_subtop"> 
		<tr>
			'.($panel==""?'
			'.$seo.'<td class="cell">&nbsp;<img src="'.$env["http_path"].'usr/system/images/title.gif" height="14" width="12" alt="TITLE" />&nbsp;<b>TITLE:</b>&nbsp;'.$env["document.title"].'</td>
			'.($env["user"]["GROUP"]=="wheel"?'<td class="cell">&nbsp;&nbsp;<img src="'.$env["http_path"].'usr/system/images/template.gif" height="14" width="12" alt="'.$lang["Template_select"].'" />&nbsp;<b>'.$lang["Template_select"].':</b> <a href="'.$env["http_path"].'?option=edit_template&name='.$env["document.template"].'" style="color: black; text-decoration: none">'.($env["document.template"]).'</a></td>':'').
			'<td class="cell">&nbsp;&nbsp;<img src="'.$env["http_path"].'usr/system/images/sapid_sp_user.gif" height="14" width="12" alt="'.$lang["User"].'" />&nbsp;<b>'.$lang["User"].':</b> '.$env["user.login"].'&nbsp;<b>'.$lang["Group"].':</b> '.$env["user.usergroup"].'</td>
			'.$data_info.'
			':'<td><img src="'.$env["http_path"].'usr/system/images/x.gif" height="24" width="1" /></td>
			<td style="CURSOR: pointer" onclick="window.open(\''.$env["http_path"].'/usr/system/communicator/index.php\', \'communicator\', \'width=600, height=450, status=no,toolbar=no,menubar=no, scrollbars=no, resizable=no\');" style="padding: 0px 0px 0px 5px; vertical-align: middle;"><img src="'.$env["http_path"].'usr/system/images/messenger.gif" height="14" width="12" alt="'.$lang["messenger_desc"].'" /></td>
			<td class="cell" title="'.$lang["messenger_desc"].'"><b><a style="color: #003263; font-size: 12px; CURSOR: pointer" onclick="window.open(\''.$env["http_path"].'usr/system/communicator/index.php\', \'communicator\', \'width=600, height=450, status=no,toolbar=no,menubar=no, scrollbars=no, resizable=no\');" title="'.$lang["messenger_desc"].'">'.$lang["messenger_title"].'</a></b></td>
			'.$title_info_gray.$data_info_gray).' 
			
		</tr>
	</table>
	</td>
</tr>
<tr>
	<td colspan="14" width="100%" height="1px"></td>
</tr>
</table>
'.($panel==""?'<div style="background: url(../../usr/templates/images/bbg.gif) repeat-x; background-color: #D4E5F3; border: 1px solid white; width: 107px; font-family: Verdana, Arial; font-size: 10px; font-weight: bold; text-align: center; padding: 2px; cursor: pointer;" onclick="slidebar()">Show/hide panel</div>
</div>':'<div style="width: 100%; height: 20px; background-color: white">&nbsp;</div>
<div style="width: 100%; background-color: #CEE4F2; border-bottom: 2px solid white;"><img src="'.$env["http_path"].'usr/system/images/x.gif" height="5" width="1" /></div>
');	

if(file_exists(ROOT_PATH."usr/system/cache/restore.timestamp.txt")) {
$restore_tdump = @file_get_contents(ROOT_PATH."usr/system/cache/restore.timestamp.txt");
if($restore_tdump)
	print '<div style="position: absolute; z-index: 20000; color: white; top: 15px; left: 640px; font-family: Arial; font-size: 11px; font-weight: bold; "><i>Count Down: '.gmdate("H:i:s", 1800 - (time()-$restore_tdump)).'</i></div>	';
}
?>